Skip to content

[ApplicationInsights] removing env var reads from hot path#1996

Merged
brettsam merged 3 commits intomainfrom
brettsam/ai_envvars
Oct 31, 2023
Merged

[ApplicationInsights] removing env var reads from hot path#1996
brettsam merged 3 commits intomainfrom
brettsam/ai_envvars

Conversation

@brettsam
Copy link
Copy Markdown
Member

@brettsam brettsam commented Oct 27, 2023

resolves #1827

During the (long) investigation into the issue above we have found that in some cases environment variable reads can be very expensive in App Service. But we cannot fully cache the variables because during certain App Service events (slot swaps, for example), the environment variables can change out from underneath us.

This change adds a background monitor to watch for the changes in these few environment variables, then triggers an Options change when it occurs. This keeps the expensive reads off the hot path.

Pull request checklist

  • My changes do not require documentation changes
    • Otherwise: Documentation issue linked to PR
  • My changes should not be added to the release notes for the next release
    • Otherwise: I've added my notes to release_notes.md
  • My changes do not need to be backported to a previous version
    • Otherwise: Backport tracked by issue/PR #issue_or_pr
  • I have added all required tests (Unit tests, E2E tests)

Comment thread src/DotNetWorker.ApplicationInsights/Initializers/AppServiceOptionsInitializer.cs Outdated
@brettsam brettsam merged commit 4e8849e into main Oct 31, 2023
@brettsam brettsam deleted the brettsam/ai_envvars branch October 31, 2023 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8x Performance degradation after updating Microsoft.Azure.Functions.Worker.Extensions.ApplicationInsights package

2 participants